﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ZenKee.Modules.ListPages.Components
{
    public class Pager
    {
        private int m_PageSize;
        private int m_RecordCount;
        private int m_PageIndex;
        private int m_MaxShowIndex;

        public int PageSize
        {
            get { return m_PageSize; }
            set { m_PageSize = value; }
        }

        public int RecordCount
        {
            get { return m_RecordCount; }
            set { m_RecordCount = value; }
        }

        public int PageIndex
        {
            get { return m_PageIndex; }
            set { m_PageIndex = value; }
        }

        public int MaxShowIndex
        {
            get { return m_MaxShowIndex; }
            set { m_MaxShowIndex = value; }
        }

        public int PageCount
        {
            get
            {
                if (PageSize != 0)
                {
                    if (RecordCount < PageSize)
                    {
                        return 1;
                    }
                    int pagecount = RecordCount / PageSize;
                    if ((RecordCount / PageSize) * PageSize == RecordCount)
                    {
                        return pagecount;
                    }
                    else
                    {
                        return pagecount + 1;
                    }
                }
                return 0;
            }
        }
    }
}
